package com.ruoyi.graduate.controller;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.graduate.domain.entity.MsFinishedProduct;
import com.ruoyi.graduate.domain.param.MsFinishedProductAddParam;
import com.ruoyi.graduate.domain.param.MsFinishedProductAuditParam;
import com.ruoyi.graduate.domain.param.MsFinishedProductPageParam;
import com.ruoyi.graduate.domain.param.MsFinishedProductPagePhotoParam;
import com.ruoyi.graduate.service.IMsFinishedProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * 成品信息控制接口
 */
@RestController
@RequestMapping("/api/product")
@Api(tags = "成品信息控制接口")
public class MsFinishedProductController extends BaseController {

    @Autowired
    private IMsFinishedProductService msFinishedProductService;


    @ApiOperation("获取成品分页信息")
    @GetMapping
    public TableDataInfo pageList(MsFinishedProductPageParam param) {
        PageInfo pageInfo = msFinishedProductService.finishiPage(param);

        return getDataTable(pageInfo.getList(), pageInfo.getTotal());
    }


    @ApiOperation("摄影师获取成品分页信息")
    @GetMapping("/photopage")
    public TableDataInfo pagePhotoList(MsFinishedProductPagePhotoParam param) {
        PageInfo pageInfo = msFinishedProductService.finishiPagePhoto(param);

        return getDataTable(pageInfo.getList(), pageInfo.getTotal());
    }


    @ApiOperation("成品信息详情查询")
    @GetMapping("{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {

        return msFinishedProductService.detail(id);

    }


    @ApiOperation("成品信息审核")
    @PutMapping
    public AjaxResult edit(@RequestBody MsFinishedProductAuditParam param) {
        return msFinishedProductService.audit(param);
    }


    @ApiOperation("成品信息删除")
    @DeleteMapping("{id}")
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult remove(@PathVariable("id") Integer id) {
        boolean b = msFinishedProductService.removeById(id);

        return b ? AjaxResult.success() : AjaxResult.error();
    }


    @ApiOperation("成品信息新增")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody MsFinishedProductAddParam param) {
        return msFinishedProductService.add(param);
    }


    @ApiOperation("用户端成品列表查询")
    @GetMapping("/userList/{customer_id}")
    public AjaxResult userList(@PathVariable Long customer_id) {

        return msFinishedProductService.userList(customer_id);
    }

    
}
